package com.small.common.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;

import java.util.Map;

/**
 * fastjson工具类
 *
 * @author dingyou
 * @version 1.0
 * @date 2018/9/15
 */
public class FastJsonUtils {

    /**
     * 将json转成Map
     *
     * @param json
     * @param keyType
     * @param valueType
     * @param <K>
     * @param <V>
     * @return
     */
    public static <K, V> Map<K, V> parseToMap(String json, Class<K> keyType, Class<V> valueType) {
        return JSON.parseObject(json, new TypeReference<Map<K, V>>(keyType, valueType) {
        });
    }

    private FastJsonUtils() {
    }
}
